function strTrim(str) {
    str = str.replace(/(^\s*)|(\s*$)/g, "");
    return str;
}
function serializeJson(obj) {
    var serializeObj = {};
    var array = obj.serializeArray();
    var str = obj.serialize();
    $(array).each(function () {
        if (serializeObj[this.name]) {
            if ($.isArray(serializeObj[this.name])) {
                serializeObj[this.name].push(this.value);
            } else {
                serializeObj[this.name] = [serializeObj[this.name], this.value];
            }
        } else {
            serializeObj[this.name] = this.value;
        }
    });
    return serializeObj;
}
function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
}
function timestr(fmt, time) {
    var now = time ? new Date(time) : new Date();
    var o = {
        "M+": now.getMonth() + 1,                 //月份
        "d+": now.getDate(),                    //日
        "h+": now.getHours(),                   //小时
        "m+": now.getMinutes(),                 //分
        "s+": now.getSeconds(),                 //秒
        "q+": Math.floor((now.getMonth() + 3) / 3), //季度
        "S": now.getMilliseconds()             //毫秒
    };
    if (/(y+)/.test(fmt))
        fmt = fmt.replace(RegExp.$1, (now.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt))
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}
function clone(obj) {
    var o;
    switch (typeof obj) {
        case "undefined":
            break;
        case "string":
            o = obj + "";
            break;
        case "number":
            o = obj - 0;
            break;
        case "boolean":
            o = obj;
            break;
        case "object": // object 分为两种情况 对象（Object）或数组（Array）
            if (obj === null) {
                o = null;
            } else {
                if (Object.prototype.toString.call(obj).slice(8, -1) === "Array") {
                    o = [];
                    for (var i = 0; i < obj.length; i++) {
                        o.push(clone(obj[i]));
                    }
                } else {
                    o = {};
                    for (var k in obj) {
                        o[k] = clone(obj[k]);
                    }
                }
            }
            break;
        default:
            o = obj;
            break;
    }
    return o;
}
function random(min, max) {
    return Math.floor(Math.random() * (max - min + 1) + min);
}
function loadScript(url, callback) {
    var script = document.createElement("script");
    script.type = "text/javascript";
    if (typeof (callback) != "undefined") {
        if (script.readyState) {
            script.onreadystatechange = function () {
                if (script.readyState == "loaded" || script.readyState == "complete") {
                    script.onreadystatechange = null;
                    callback();
                }
            };
        } else {
            script.onload = function () {
                callback();
            };
        }
    }
    script.src = url;
    document.body.appendChild(script);
}
function isEmpty(value) {
    var result = false;
    console.log(typeof value);
    switch (typeof value) {
        case 'string':
            result = value == '';
            break;
        case 'undefined':
            result = true;
            break;
        case 'number':
            result = false;
            break;
        case 'object':
            var tmp = JSON.stringify(value);
            result = tmp == '{}' || tmp == '[]' ? true : false;
            break;
    }
    return result;
}
function formatAmount(txt) {
    txt = BigInt(txt) / BigInt(1e18);
    return txt;
}